<p>
  <%= link_to 'Back', pageants_url(@pageant) %> |
  <%= link_to 'New Score', new_pageant_score_path %> | 
  <%= link_to 'Destroy All Scores', destroy_all_pageant_scores_url, :method=>:delete, :confirm=>"Are you sure?" %> | 
  <%= link_to 'Printable Detailed Report', report_pageant_scores_url(:format=>:pdf)%> |  
  <%= link_to 'Printable Simple Report', simple_report_pageant_scores_url(:format=>:pdf)%> |
    <%= link_to 'Logout', :controller => :admins, :action => 'logout'%>
</p>

<h2>Scores <% if not Score.scoring_locked?(@pageant)%>(Incomplete)<% end %></h2>

<table>
  <tr>
    <th></th>
      <% @contestants.each do |c| -%>
        <th align="center"><%= c.position %></th>
      <% end -%>
  </tr>
  <% @rounds.each do |r| -%>
    <tr><th colspan="<%= @contestants.size+1%>"><%= r.position %>. <%= r.description %> (<%= r.max_score %>)</th></tr>
    <% if r.manual -%>
      <tr><td>&nbsp&nbsp&nbsp&nbsp Manual</td>
      <% @contestants.each do |c| -%>
        <%= render(:partial => '/scores/showscore', :locals => {:pageant_id => @pageant.id, :contestant_id => c.id, :judge_id=>nil, :round_id=>r.id}) -%>
      <% end -%>
      </tr>
    <% else %>
      <% @judges.each do |j| -%>
        <tr>
          <td>&nbsp&nbsp&nbsp&nbsp <%= j.alias %></td>
          <% @contestants.each do |c| -%>
            <%= render(:partial => '/scores/showscore', :locals => {:pageant_id => @pageant.id, :contestant_id => c.id, :judge_id=>j.id, :round_id=>r.id}) -%>
          <% end -%>
        </tr>
      <% end -%>
      <tr>
        <th>&nbsp&nbsp&nbsp&nbsp Averages</th>
        <% @contestants.each do |c| -%>
          <td align="right"><%= number_with_precision(Score.round_average_for_contestant(r, c),:precision=>2) %> (<%= @round_rankings[r.id][c.id] %>)</td>
        <% end -%>
      </tr>
    <% end %>
    <tr><td>&nbsp</td></tr>
  <% end -%>
  <tr><td>&nbsp</td></tr>
  <tr><th colspan="<%=@contestants.size%>">Judge Totals</th></tr>
  <% @judges.each do |j| -%>
    <tr>
      <td>&nbsp&nbsp&nbsp&nbsp <%= j.alias %></td>
      <% @contestants.each do |c| %>
        <td align="right"><%= number_with_precision(Score.judge_total_for_contestant(j, c),:precision=>2) %> (<%= @judge_rankings[j.id][c.id]%>)</td>
      <% end -%>
    </tr>
  <% end -%>
  <tr><td>&nbsp</td></tr>
  <tr>
    <th>Grand Totals</th>
    <% @contestants.each do |c| -%>
      <td align="right"><b><%= number_with_precision(Score.score_for_contestant(c),:precision=>2) %> (<%= @rankings[c.id]%>)</b></td>
    <% end -%>
  </tr>
</table>
